﻿#region Copyright (c) 2000-2013 Developer Express Inc.
/*
{*******************************************************************}
{                                                                   }
{       Developer Express .NET Component Library                    }
{                                                                   }
{                                                                   }
{       Copyright (c) 2000-2013 Developer Express Inc.              }
{       ALL RIGHTS RESERVED                                         }
{                                                                   }
{   The entire contents of this file is protected by U.S. and       }
{   International Copyright Laws. Unauthorized reproduction,        }
{   reverse-engineering, and distribution of all or any portion of  }
{   the code contained in this file is strictly prohibited and may  }
{   result in severe civil and criminal penalties and will be       }
{   prosecuted to the maximum extent possible under the law.        }
{                                                                   }
{   RESTRICTIONS                                                    }
{                                                                   }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES           }
{   ARE CONFIDENTIAL AND PROPRIETARY TRADE                          }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS   }
{   LICENSED TO DISTRIBUTE THE PRODUCT AND ALL ACCOMPANYING .NET    }
{   CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY.                 }
{                                                                   }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED      }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE        }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE       }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT  }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                      }
{                                                                   }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON       }
{   ADDITIONAL RESTRICTIONS.                                        }
{                                                                   }
{*******************************************************************}
*/
#endregion Copyright (c) 2000-2013 Developer Express Inc.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UColor.Core.Helpers;
using System.Collections.ObjectModel;
using System.Windows.Input;
namespace UColor.WPF.Internal {
	public sealed class BaseControlModulesPage : BaseControlOrdinarPart {
		WeakEventHandler<ThePropertyChangedEventArgs<object>> onDemoBaseControlStateProductIDChanged;
		string filterText = string.Empty;
		bool useAnimation = true;
        BaseControlPagesContainer CtrlPageContainer;
        public BaseControlModulesPage(BaseControlPagesContainer pageContainer,BaseControl demoBaseControl)
			: base(demoBaseControl) {
                CtrlPageContainer = pageContainer;
			onDemoBaseControlStateProductIDChanged = new WeakEventHandler<ThePropertyChangedEventArgs<object>>(OnDemoBaseControlStateProductIDChanged);
			UseAnimation = true;
			demoBaseControl.ActualPageChanged += OnActualPageChanged;
			Initialized();
		}
		protected override void BeginLoadData() {
			//DemoBaseControl.Data.LoadProducts(BeginInMainThread);
			base.BeginLoadData();
		}
		protected override void EndLoadData() {
			base.EndLoadData();
			
			
		}
        public void OpenModule(UCModule module)
        {
            CtrlPageContainer.MainPage.ModuleWrapper.LoadModule(module);
        }
		protected override void OnDemoBaseControlStateChanged(BaseControlState oldValue, BaseControlState newValue) {
			base.OnDemoBaseControlStateChanged(oldValue, newValue);
			if(oldValue != null)
				oldValue.ProductIDChanged -= onDemoBaseControlStateProductIDChanged.Handler;
			if(newValue != null) {
				newValue.ProductIDChanged += onDemoBaseControlStateProductIDChanged.Handler;
				OnDemoBaseControlStateProductIDChanged(newValue, new ThePropertyChangedEventArgs<object>(null, newValue.ProductID));
			}
		}
		void OnActualPageChanged(object sender, DepPropertyChangedEventArgs e) {
			if((BaseControlPage)e.NewValue == BaseControlPage.ModulesPage)
				UseAnimation = true;
			else
				UseAnimation = false;
		}
		void OnDemoBaseControlStateProductIDChanged(object sender, ThePropertyChangedEventArgs<object> e) {
			
		}
		
		public string FilterText {
			get { return filterText; }
			set { SetValue<string>("FilterText", ref filterText, value, RaiseFilterTextChanged); }
		}
		public bool UseAnimation {
			get { return useAnimation; }
			private set { SetValue<bool>("UseAnimation", ref useAnimation, value); }
		}
		
		void RaiseFilterTextChanged(string oldValue, string newValue) {
			
		}
		
		#region Commands
		protected override void InitializeCommands() {
			base.InitializeCommands();
			
		}
		public ICommand RaiseActualProductChangedCommand { get; private set; }
		
		#endregion
	}
}
